-
Notifications
You must be signed in to change notification settings - Fork 881
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert Elasticsearch Transport to Instrumenter API (#4252)
* Convert Elasticsearch Transport to Instrumenter API * Don't set duplicate attributes * Code review comments
- Loading branch information
Showing
28 changed files
with
613 additions
and
586 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
.../elasticsearch/transport/v5_0/Elasticsearch5TransportExperimentalAttributesExtractor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.v5_0; | ||
|
||
import io.opentelemetry.api.common.AttributesBuilder; | ||
import io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.ElasticTransportRequest; | ||
import io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.ElasticsearchTransportExperimentalAttributesExtractor; | ||
import org.elasticsearch.action.DocumentRequest; | ||
|
||
public class Elasticsearch5TransportExperimentalAttributesExtractor | ||
extends ElasticsearchTransportExperimentalAttributesExtractor { | ||
|
||
@Override | ||
protected void onStart(AttributesBuilder attributes, ElasticTransportRequest transportRequest) { | ||
super.onStart(attributes, transportRequest); | ||
|
||
Object request = transportRequest.getRequest(); | ||
if (request instanceof DocumentRequest) { | ||
DocumentRequest<?> req = (DocumentRequest<?>) request; | ||
attributes.put("elasticsearch.request.write.type", req.type()); | ||
attributes.put("elasticsearch.request.write.routing", req.routing()); | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...agent/instrumentation/elasticsearch/transport/v5_0/Elasticsearch5TransportSingletons.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.v5_0; | ||
|
||
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; | ||
import io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.ElasticTransportNetAttributesExtractor; | ||
import io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.ElasticTransportRequest; | ||
import io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.ElasticsearchTransportInstrumenterFactory; | ||
import org.elasticsearch.action.ActionResponse; | ||
|
||
public final class Elasticsearch5TransportSingletons { | ||
|
||
private static final Instrumenter<ElasticTransportRequest, ActionResponse> INSTRUMENTER = | ||
ElasticsearchTransportInstrumenterFactory.create( | ||
"io.opentelemetry.elasticsearch-transport-5.0", | ||
new Elasticsearch5TransportExperimentalAttributesExtractor(), | ||
new ElasticTransportNetAttributesExtractor()); | ||
|
||
public static Instrumenter<ElasticTransportRequest, ActionResponse> instrumenter() { | ||
return INSTRUMENTER; | ||
} | ||
|
||
private Elasticsearch5TransportSingletons() {} | ||
} |
144 changes: 0 additions & 144 deletions
144
...metry/javaagent/instrumentation/elasticsearch/transport/v5_0/TransportActionListener.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.