GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Surface process tags on telemetry payloads by amarziali · Pull Request #8837 · DataDog/dd-trace-java

Surface process tags on telemetry payloads #8837

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.

Sign up for GitHub

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

Merged
amarziali merged 1 commit into master from andrea.marziali/telemetry
May 22, 2025

Uh oh!

There was an error while loading. Please reload this page.

Merged

Surface process tags on telemetry payloads #8837

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1 commit
Select commit
1c0de44
Surface process tags on telemetry payloads
amarziali May 16, 2025
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

5 changes: 5 additions & 0 deletions 5 telemetry/src/main/java/datadog/telemetry/TelemetryRequestBody.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import datadog.trace.api.ConfigSetting;
import datadog.trace.api.DDTags;
import datadog.trace.api.Platform;
import datadog.trace.api.ProcessTags;
import datadog.trace.api.telemetry.Endpoint;
import datadog.trace.api.telemetry.ProductChange.ProductType;
import java.io.IOException;
Expand Down Expand Up @@ -87,6 +88,10 @@ public void beginRequest(boolean debug) {
bodyWriter.name("runtime_name").value(commonData.runtimeName);
bodyWriter.name("runtime_version").value(commonData.runtimeVersion);
bodyWriter.name("runtime_patches").value(commonData.runtimePatches); // optional
final CharSequence processTags = ProcessTags.getTagsForSerialization();
if (processTags != null) {
bodyWriter.name("process_tags").value(processTags.toString());
}
bodyWriter.endObject();

if (debug) {
Expand Down
48 changes: 41 additions & 7 deletions 48 telemetry/src/test/groovy/datadog/telemetry/TelemetryRequestBodySpecification.groovy
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
package datadog.telemetry


import com.squareup.moshi.Moshi
import com.squareup.moshi.Types
import datadog.telemetry.api.RequestType
import datadog.trace.api.ConfigOrigin
import datadog.trace.api.ConfigSetting
import datadog.trace.api.ProcessTags
import datadog.trace.api.telemetry.ProductChange
import okio.Buffer
import datadog.trace.test.util.DDSpecification
import okhttp3.RequestBody
import spock.lang.Specification
import okio.Buffer

import static datadog.trace.api.config.GeneralConfig.EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED
import static datadog.trace.api.telemetry.ProductChange.ProductType.APPSEC
import static datadog.trace.api.telemetry.ProductChange.ProductType.DYNAMIC_INSTRUMENTATION
import static datadog.trace.api.telemetry.ProductChange.ProductType.PROFILER

/**
* This test only verifies non-functional specifics that are not covered in TelemetryServiceSpecification
*/
class TelemetryRequestBodySpecification extends Specification {
class TelemetryRequestBodySpecification extends DDSpecification {

def 'throw SerializationException in case of JSON nesting problem'() {
setup:
Expand Down Expand Up @@ -112,17 +117,17 @@ class TelemetryRequestBodySpecification extends Specification {
drainToString(req).contains("\"debug\":true")
}

void 'test writeProducts'(){
void 'test writeProducts'() {
setup:
TelemetryRequestBody req = new TelemetryRequestBody(RequestType.APP_PRODUCT_CHANGE)
final products = new HashMap<ProductChange.ProductType, Boolean>()
if(appsecChange) {
if (appsecChange) {
products.put(APPSEC, appsecEnabled)
}
if(profilerChange) {
if (profilerChange) {
products.put(PROFILER, profilerEnabled)
}
if(dynamicInstrumentationChange) {
if (dynamicInstrumentationChange) {
products.put(DYNAMIC_INSTRUMENTATION, dynamicInstrumentationEnabled)
}

Expand Down Expand Up @@ -154,4 +159,33 @@ class TelemetryRequestBodySpecification extends Specification {
buf.read(bytes)
return new String(bytes)
}

def 'Should propagate process tags when enabled #processTagsEnabled'() {
setup:
injectSysConfig(EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED, "$processTagsEnabled")
ProcessTags.reset()
TelemetryRequestBody req = new TelemetryRequestBody(RequestType.APP_STARTED)

when:
req.beginRequest(true)
req.endRequest()

then:
def type = Types.newParameterizedType(Map, String, Object)
def adapter = new Moshi.Builder().build().adapter(type)
def parsed = (Map<String, Object>)adapter.fromJson(drainToString(req))
def parsedTags = ((Map<String, Object>)parsed.get("application")).get("process_tags")
if (processTagsEnabled) {
assert parsedTags == ProcessTags.tagsForSerialization.toString()
Comment thread Outdated

@ygree ygree May 21, 2025

Copy link
Copy Markdown
Contributor

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.

Not critical, but expected parsed tags could be a data column to avoid this conditional logic here

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
} else {
assert parsedTags == null
}

cleanup:
injectSysConfig(EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED, "false")
ProcessTags.reset()

where:
processTagsEnabled << [true, false]
}
}
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.