Commit 9e072620 authored by Liuhaoyang's avatar Liuhaoyang

Refactor

parent 6fcdeb8f
......@@ -27,18 +27,15 @@ namespace SkyWalking.Context.Trace
private long _timestamp = 0;
private Dictionary<string, string> _logs;
private LogDataEntity(long timestamp,Dictionary<string,string> logs)
private LogDataEntity(long timestamp, Dictionary<string, string> logs)
{
_timestamp = timestamp;
_logs = logs;
}
public IReadOnlyDictionary<string,string> Logs
public IReadOnlyDictionary<string, string> Logs
{
get
{
return new ReadOnlyDictionary<string, string>(_logs);
}
get { return new ReadOnlyDictionary<string, string>(_logs); }
}
public class Builder
......@@ -57,7 +54,7 @@ namespace SkyWalking.Context.Trace
return this;
}
public Builder Add(string key,string value)
public Builder Add(string key, string value)
{
_logs.Add(key, value);
return this;
......@@ -73,10 +70,11 @@ namespace SkyWalking.Context.Trace
{
LogMessage logMessage = new LogMessage();
logMessage.Time = _timestamp;
foreach(var log in _logs)
foreach (var log in _logs)
{
logMessage.Data.Add(new KeyWithStringValue { Key = log.Key, Value = log.Value });
logMessage.Data.Add(new KeyWithStringValue {Key = log.Key, Value = log.Value});
}
return logMessage;
}
}
......
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Text;
namespace SkyWalking.Context
{
public static class ExceptionExtensions
{
public static string ConvertToString(Exception exception, int maxLength)
{
var message = new StringBuilder();
while (exception != null)
{
message.Append(exception.Message);
PrintStackFrame(message, exception.StackTrace, maxLength, out var overMaxLength);
if (overMaxLength)
{
break;
}
exception = exception.InnerException;
}
return message.ToString();
}
private static void PrintStackFrame(StringBuilder message, string stackTrace,
int maxLength, out bool overMaxLength)
{
message.AppendLine(stackTrace);
overMaxLength = message.Length > maxLength;
}
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
using SkyWalking.NetworkProtocol;
namespace SkyWalking.Context
{
public class KeyValuePair
{
public string Key { get; }
public string Value { get; }
public KeyValuePair(string key, string value)
{
Key = key;
Value = value;
}
public KeyWithStringValue Transform()
{
var keyWithStringValue = new KeyWithStringValue
{
Key = Key,
Value = Value
};
return keyWithStringValue;
}
}
}
using System.Collections.Generic;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
using System.Collections.Generic;
using System.Linq;
using SkyWalking.Context.Ids;
using SkyWalking.Dictionarys;
......
namespace SkyWalking.Context
{
public class TracingContext
{
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment