Skip to content
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

Adds datadog tags to traces for restore and app installs #1547

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package org.commcare.formplayer.services;

import io.opentracing.Span;
import io.opentracing.util.GlobalTracer;
import org.commcare.formplayer.util.FormplayerDatadog;
import org.commcare.formplayer.util.Constants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Component;

import datadog.trace.api.interceptor.MutableSpan;

@Component
@Scope(value = "request", proxyMode = ScopedProxyMode.TARGET_CLASS)
public class ResponseMetaDataTracker {
Expand All @@ -23,6 +27,11 @@
}

public void setAttemptRestore(boolean attemptRestore) {
final Span span = GlobalTracer.get().activeSpan();

Check warning on line 30 in src/main/java/org/commcare/formplayer/services/ResponseMetaDataTracker.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/commcare/formplayer/services/ResponseMetaDataTracker.java#L30

Added line #L30 was not covered by tests
if (span != null && (span instanceof MutableSpan)) {
Comment on lines +30 to +31
Copy link
Contributor

@nospame nospame Mar 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this want to use a check similar to the one added here dimagi/commcare-core@fcdceca ?

MutableSpan localRootSpan = ((MutableSpan) span).getLocalRootSpan();
localRootSpan.setTag("attempt_restore", attemptRestore);

Check warning on line 33 in src/main/java/org/commcare/formplayer/services/ResponseMetaDataTracker.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/commcare/formplayer/services/ResponseMetaDataTracker.java#L32-L33

Added lines #L32 - L33 were not covered by tests
}
datadog.addRequestScopedTag(Constants.CATEGORY_TAG, Constants.TimingCategories.COMPLETE_RESTORE);
this.attemptRestore = attemptRestore;
}
Expand All @@ -32,6 +41,11 @@
}

public void setNewInstall(boolean newInstall) {
final Span span = GlobalTracer.get().activeSpan();
if (span != null && (span instanceof MutableSpan)) {
MutableSpan localRootSpan = ((MutableSpan) span).getLocalRootSpan();
localRootSpan.setTag("new_install", newInstall);

Check warning on line 47 in src/main/java/org/commcare/formplayer/services/ResponseMetaDataTracker.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/commcare/formplayer/services/ResponseMetaDataTracker.java#L46-L47

Added lines #L46 - L47 were not covered by tests
}
datadog.addRequestScopedTag(Constants.CATEGORY_TAG, Constants.TimingCategories.APP_INSTALL);
this.newInstall = newInstall;
}
Expand Down
Loading