-
Notifications
You must be signed in to change notification settings - Fork 311
Container hash tags propagation #9282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
9f5d390
c7a35b2
d199ffd
0e28803
bc7eefb
1992f14
e0a0a1a
8eb36bc
b27ca85
620c3ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,9 +7,9 @@ | |
import com.datadoghq.sketch.ddsketch.encoding.ByteArrayInput; | ||
import com.datadoghq.sketch.ddsketch.encoding.GrowingByteArrayOutput; | ||
import com.datadoghq.sketch.ddsketch.encoding.VarEncodingHelper; | ||
import datadog.common.container.ContainerInfo; | ||
import datadog.context.propagation.CarrierVisitor; | ||
import datadog.trace.api.Config; | ||
import datadog.trace.api.ProcessTags; | ||
import datadog.trace.api.ServiceHash; | ||
import datadog.trace.api.WellKnownTags; | ||
import datadog.trace.api.datastreams.DataStreamsContext; | ||
import datadog.trace.api.datastreams.DataStreamsTags; | ||
|
@@ -269,19 +269,7 @@ private static DefaultPathwayContext decode( | |
} | ||
|
||
public static long getBaseHash(WellKnownTags wellKnownTags) { | ||
StringBuilder builder = new StringBuilder(); | ||
builder.append(wellKnownTags.getService()); | ||
builder.append(wellKnownTags.getEnv()); | ||
|
||
String primaryTag = Config.get().getPrimaryTag(); | ||
if (primaryTag != null) { | ||
builder.append(primaryTag); | ||
} | ||
CharSequence processTags = ProcessTags.getTagsForSerialization(); | ||
if (processTags != null) { | ||
builder.append(processTags); | ||
} | ||
return FNV64Hash.generateHash(builder.toString(), FNV64Hash.Version.v1); | ||
return ServiceHash.getBaseHash(wellKnownTags, ContainerInfo.get().getContainerTagsHash()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extract this into the ServiceHash class so that it is available in the DBM instrumentation. |
||
} | ||
|
||
private long generatePathwayHash(long nodeHash, long parentHash) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package datadog.trace.api; | ||
|
||
import datadog.trace.util.FNV64Hash; | ||
|
||
public final class ServiceHash { | ||
|
||
public static long getBaseHash(WellKnownTags wellKnownTags, String containerTagsHash) { | ||
return getBaseHash( | ||
wellKnownTags.getService(), | ||
wellKnownTags.getEnv(), | ||
Config.get().getPrimaryTag(), | ||
ProcessTags.getTagsForSerialization(), | ||
containerTagsHash); | ||
} | ||
|
||
public static long getBaseHash( | ||
CharSequence serviceName, CharSequence env, String containerTagsHash) { | ||
return getBaseHash( | ||
serviceName, | ||
env, | ||
Config.get().getPrimaryTag(), | ||
ProcessTags.getTagsForSerialization(), | ||
containerTagsHash); | ||
} | ||
|
||
private static long getBaseHash( | ||
CharSequence serviceName, | ||
CharSequence env, | ||
String primaryTag, | ||
CharSequence processTags, | ||
String containerTagsHash) { | ||
StringBuilder builder = new StringBuilder(); | ||
builder.append(serviceName); | ||
builder.append(env); | ||
|
||
if (primaryTag != null) { | ||
builder.append(primaryTag); | ||
} | ||
if (processTags != null) { | ||
builder.append(processTags); | ||
if (containerTagsHash != null && !containerTagsHash.isEmpty()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Populate the base hash with the container tag hash if the process tag propagation feature flag is. |
||
builder.append(containerTagsHash); | ||
} | ||
} | ||
return FNV64Hash.generateHash(builder.toString(), FNV64Hash.Version.v1); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inject the base hash into the SQL comment when the service mode is enabled.