Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
CAP
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
CAP
Commits
9d0a453a
Commit
9d0a453a
authored
Apr 10, 2018
by
Savorboard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add tracingheader helper func
parent
b3d0126d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
1 deletion
+18
-1
Helper.cs
src/DotNetCore.CAP/Infrastructure/Helper.cs
+18
-1
No files found.
src/DotNetCore.CAP/Infrastructure/Helper.cs
View file @
9d0a453a
...
...
@@ -4,6 +4,7 @@
using
System
;
using
System.ComponentModel
;
using
System.Reflection
;
using
DotNetCore.CAP.Diagnostics
;
using
Newtonsoft.Json
;
using
Newtonsoft.Json.Linq
;
...
...
@@ -48,7 +49,7 @@ namespace DotNetCore.CAP.Infrastructure
public
static
long
ToTimestamp
(
DateTime
value
)
{
var
elapsedTime
=
value
-
Epoch
;
return
(
long
)
elapsedTime
.
TotalSeconds
;
return
(
long
)
elapsedTime
.
TotalSeconds
;
}
...
...
@@ -90,6 +91,12 @@ namespace DotNetCore.CAP.Infrastructure
return
AddJsonProperty
(
json
,
"ExceptionMessage"
,
jObject
);
}
public
static
string
AddTracingHeaderProperty
(
string
json
,
TracingHeaders
headers
)
{
var
jObject
=
ToJObject
(
headers
);
return
AddJsonProperty
(
json
,
"TracingHeaders"
,
jObject
);
}
public
static
bool
IsInnerIP
(
string
ipAddress
)
{
bool
isInnerIp
;
...
...
@@ -156,6 +163,16 @@ namespace DotNetCore.CAP.Infrastructure
});
}
private
static
JObject
ToJObject
(
TracingHeaders
headers
)
{
var
jobj
=
new
JObject
();
foreach
(
var
keyValuePair
in
headers
)
{
jobj
[
keyValuePair
.
Key
]
=
keyValuePair
.
Value
;
}
return
jobj
;
}
private
static
string
AddJsonProperty
(
string
json
,
string
propertyName
,
JObject
propertyValue
)
{
var
jObj
=
JObject
.
Parse
(
json
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment