NEWSLabNTU / ddshark

A live monitoring tool for RTPS protocol.
MIT License
2 stars 2 forks source link

Support exporting OpenTelemetry traces #11

Closed st9540808 closed 1 year ago

st9540808 commented 1 year ago

ddshark will now have the command line options below. If the option --otlp-enable is set, then ddshark will export OpenTelemetry traces the the endpoint specified in --otlp-endpoint. The default endpoint is http://localhost:4317.

❯ ./target/release/ddshark --help
Usage: ddshark [OPTIONS]

Options:
      --refresh-rate <REFRESH_RATE>    [default: 4]
  -f, --file <FILE>                    
  -i, --interface <INTERFACE>          
  -o, --otlp-enable                    
  -e, --otlp-endpoint <OTLP_ENDPOINT>  [default: http://localhost:4317]
  -h, --help                           Print help

Example OpenTelemetry traces

The output below is from opentelemetry-collector-contrib. I use ddshark to process a pcap file with two DATA_FRAG submessage.

❯ ./bin/otelcontribcol_linux_amd64 --config ./examples/demo/otel-collector-config.yaml
2023-05-30T00:13:59.538+0800    info    service/telemetry.go:104    Setting up own telemetry...
2023-05-30T00:13:59.539+0800    info    service/telemetry.go:127    Serving Prometheus metrics  {"address": ":8888", "level": "Basic"}
2023-05-30T00:13:59.539+0800    info    exporter@v0.78.3-0.20230525165144-87dd85a6c034/exporter.go:275  Development component. May change in the future.    {"kind": "exporter", "data_type": "traces", "name": "logging"}
2023-05-30T00:13:59.539+0800    info    exporter@v0.78.3-0.20230525165144-87dd85a6c034/exporter.go:275  Development component. May change in the future.    {"kind": "exporter", "data_type": "metrics", "name": "logging"}
2023-05-30T00:13:59.540+0800    info    service/service.go:131  Starting otelcontribcol...  {"Version": "0.78.0-dev", "NumCPU": 32}
2023-05-30T00:13:59.540+0800    info    extensions/extensions.go:30 Starting extensions...
2023-05-30T00:13:59.540+0800    warn    internal/warning.go:40  Using the 0.0.0.0 address exposes this server to every network interface, which may facilitate Denial of Service attacks    {"kind": "exporter", "data_type": "metrics", "name": "prometheus", "documentation": "https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/security-best-practices.md#safeguards-against-denial-of-service-attacks"}
2023-05-30T00:13:59.540+0800    warn    internal/warning.go:40  Using the 0.0.0.0 address exposes this server to every network interface, which may facilitate Denial of Service attacks    {"kind": "receiver", "name": "otlp", "data_type": "traces", "documentation": "https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/security-best-practices.md#safeguards-against-denial-of-service-attacks"}
2023-05-30T00:13:59.540+0800    info    otlpreceiver@v0.78.3-0.20230525165144-87dd85a6c034/otlp.go:83   Starting GRPC server    {"kind": "receiver", "name": "otlp", "data_type": "traces", "endpoint": "0.0.0.0:4317"}
2023-05-30T00:13:59.540+0800    info    service/service.go:148  Everything is ready. Begin running and processing data.
2023-05-30T00:14:08.960+0800    info    TracesExporter  {"kind": "exporter", "data_type": "traces", "name": "logging", "resource spans": 2, "spans": 2}
2023-05-30T00:14:08.960+0800    info    ResourceSpans #0
Resource SchemaURL: 
Resource attributes:
     -> host.name: Str(st9540808-i9-13900K)
     -> service.name: Str(dds.traffic)
ScopeSpans #0
ScopeSpans SchemaURL: 
InstrumentationScope opentelemetry-otlp 0.12.0
Span #0
    Trace ID       : 089865a8f6a78ba4439dca1be5e1f804
    Parent ID      : 
    ID             : af26f4637edec4e9
    Name           : DATA_FRAG
    Kind           : Internal
    Start time     : 2023-05-16 06:49:44.611157 +0000 UTC
    End time       : 2023-05-16 06:49:44.611162376 +0000 UTC
    Status code    : Unset
    Status message : 
Attributes:
     -> event.name: Str(eno2)
     -> topic_name: Str(<none>)
     -> writer_id: Str(01:10:59:06:e3:25:a3:7e:93:91:ab:42:00:00:37:03)
     -> traffic_type: Str(USER_DEFINED)
     -> payload_size: Int(13440)
     -> sn: Int(107)
ResourceSpans #1
Resource SchemaURL: 
Resource attributes:
     -> host.name: Str(st9540808-i9-13900K)
     -> service.name: Str(dds.traffic)
ScopeSpans #0
ScopeSpans SchemaURL: 
InstrumentationScope opentelemetry-otlp 0.12.0
Span #0
    Trace ID       : 4c5088952b038d52e87aa441f0db497f
    Parent ID      : 
    ID             : 0d562ec4e57317c7
    Name           : DATA_FRAG
    Kind           : Internal
    Start time     : 2023-05-16 06:49:44.611195 +0000 UTC
    End time       : 2023-05-16 06:49:44.611200376 +0000 UTC
    Status code    : Unset
    Status message : 
Attributes:
     -> payload_size: Int(13440)
     -> event.name: Str(eno2)
     -> topic_name: Str(<none>)
     -> writer_id: Str(01:10:59:06:e3:25:a3:7e:93:91:ab:42:00:00:37:03)
     -> traffic_type: Str(USER_DEFINED)
     -> sn: Int(107)
    {"kind": "exporter", "data_type": "traces", "name": "logging"}