Skip to content

Commit

Permalink
Add doAddStringLabel method
Browse files Browse the repository at this point in the history
  • Loading branch information
felixbarny committed Feb 28, 2019
1 parent bb8f094 commit 65e229e
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,14 @@ private void doSetTypes(Object span, String type, @Nullable String subtype, @Nul
// co.elastic.apm.agent.plugin.api.AbstractSpanInstrumentation$SetTypesInstrumentation.doSetType
}

// not renaming to doAddStringLabel so that API and agent versions don't have to match
// keep for backwards compatibility reasons
@Deprecated
void doAddTag(String key, String value) {
// co.elastic.apm.agent.plugin.api.AbstractSpanInstrumentation$AddTagInstrumentation
// co.elastic.apm.agent.plugin.api.AbstractSpanInstrumentation$AddStringLabelInstrumentation
}

void doAddStringLabel(String key, String value) {
// co.elastic.apm.agent.plugin.api.AbstractSpanInstrumentation$AddStringLabelInstrumentation
}

void doAddNumberLabel(String key, Number value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public Span addTag(String key, String value) {
@Nonnull
@Override
public Span addLabel(String key, String value) {
doAddTag(key, value);
doAddStringLabel(key, value);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public Transaction addTag(String key, String value) {
@Nonnull
@Override
public Transaction addLabel(String key, String value) {
doAddTag(key, value);
doAddStringLabel(key, value);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ public void resetState() {

public void copyFrom(Id other) {
System.arraycopy(other.data, 0, data, 0, data.length);
onMutation(other.empty);
this.cachedStringRepresentation = other.cachedStringRepresentation;
this.empty = other.empty;
}

private void onMutation() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public void verifyErrorSchema(JsonNode jsonNode) {
private void verifyJsonSchema(JsonSchema schema, JsonNode jsonNode) {
if (verifyJsonSchema) {
Set<ValidationMessage> errors = schema.validate(jsonNode);
assertThat(errors).isEmpty();
assertThat(errors).withFailMessage("%s\n%s", errors, jsonNode).isEmpty();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public static void getTraceId(@Advice.FieldValue(value = "span", typing = Assign

public static class AddStringLabelInstrumentation extends AbstractSpanInstrumentation {
public AddStringLabelInstrumentation() {
super(named("doAddTag"));
super(named("doAddTag").or(named("doAddStringLabel")));
}

@VisibleForAdvice
Expand Down

0 comments on commit 65e229e

Please sign in to comment.