-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(otel): add otel collector to the core crate
this commit adds otel collector APIs and a new opentelemetry feature to the wasm shim Signed-off-by: jiaxiao zhou <jiazho@microsoft.com>
- Loading branch information
Showing
15 changed files
with
444 additions
and
37 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use opentelemetry::trace::TraceError; | ||
use opentelemetry::KeyValue; | ||
use opentelemetry_otlp::WithExportConfig; | ||
use opentelemetry_sdk::{runtime, trace as sdktrace, Resource}; | ||
|
||
/// Initialize a new OpenTelemetry tracer with the OTLP exporter. | ||
/// The `otel_endpoint` is the endpoint passed down from the | ||
/// environment variable `OTEL_EXPORTER_OTLP_ENDPOINT` from Containerd. | ||
/// | ||
/// The `name` is the name of the service that will be used as a resource. | ||
/// | ||
/// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#configuration-options | ||
pub fn init_tracer( | ||
otel_endpoint: &str, | ||
name: &str, | ||
) -> Result<opentelemetry_sdk::trace::Tracer, TraceError> { | ||
opentelemetry_otlp::new_pipeline() | ||
.tracing() | ||
.with_exporter( | ||
opentelemetry_otlp::new_exporter() | ||
.tonic() | ||
.with_endpoint(otel_endpoint), | ||
) | ||
.with_trace_config( | ||
sdktrace::config().with_resource(Resource::new(vec![KeyValue::new( | ||
"service.name", | ||
name.to_string(), | ||
)])), | ||
) | ||
.install_batch(runtime::Tokio) | ||
} |
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
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
use containerd_shim_wasm::sandbox::cli::{revision, shim_main, version}; | ||
use containerd_shim_wasm::sandbox::cli::{revision, shim_main_with_otel, version}; | ||
use containerd_shim_wasmtime::WasmtimeInstance; | ||
|
||
fn main() { | ||
shim_main::<WasmtimeInstance>("wasmtime", version!(), revision!(), "v1", None); | ||
#[tokio::main] | ||
async fn main() { | ||
shim_main_with_otel::<WasmtimeInstance>("wasmtime", version!(), revision!(), "v1", None); | ||
} |