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

Add SHA512 converter. #34050

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mashhurs
Copy link

@mashhurs mashhurs commented Jul 11, 2024

Description:

Adds a converter to generate SHA-512 digest. See the #34007 issue for more details.

Link to tracking Issue: #34007

Testing:

  • Unit testing
  • E2E
  • Local testing
    • after applying changes, build opentelemetry-collector-contrib: cd opentelemetry-collector-contrib && make otelcontribcol
    • create config folder and place following config under otel-transform-sha512.yaml file:
      extensions:
        zpages:
          endpoint: 127.0.0.1:55679
      
      receivers:
        otlp:
          protocols:
            http:
              endpoint: 127.0.0.1:8080
      
      processors:
        batch:
        transform:
          log_statements:
            - context: log
              statements:
                - set(attributes["string.attribute"], SHA512(attributes["string.attribute"]))
      
      exporters:
        debug:
          verbosity: detailed
        elasticsearch:
          hosts: ["localhost:9200"]
          user: "elastic"
          password: "changeme"
          index: "otel-collector-sha256"
      
      service:
        telemetry:
          logs:
            level: debug
        pipelines:
          logs:
            receivers: [otlp]
            processors: [batch, transform]
            exporters: [elasticsearch, debug]
      
        extensions: [zpages]
      
    • run otel collector: bin/otelcontribcol_darwin_amd64 --config=config/otel-transform-sha512.yaml
    • send data
         curl --location '127.0.0.1:8080/v1/logs' \
      --header 'Content-Type: application/json' \
      --data '{
       "resourceLogs": [
         {
           "resource": {
             "attributes": [
               {
                 "key": "service.name",
                 "value": {
                   "stringValue": "my.service"
                 }
               }
             ]
           },
           "scopeLogs": [
             {
               "scope": {
                 "name": "my.library",
                 "version": "1.0.0",
                 "attributes": [
                   {
                     "key": "my.scope.attribute",
                     "value": {
                       "stringValue": "some scope attribute"
                     }
                   }
                 ]
               },
               "logRecords": [
                 {
                   "timeUnixNano": "1544712660300000000",
                   "observedTimeUnixNano": "1544712660300000000",
                   "severityNumber": 10,
                   "severityText": "Information",
                   "traceId": "5B8EFFF798038103D269B633813FC60C",
                   "spanId": "EEE19B7EC3C1B174",
                   "body": {
                     "stringValue": "Example log record"
                   },
                   "attributes": [
                     {
                       "key": "string.attribute",
                       "value": {
                         "stringValue": "sending some data for SHA512"
                       }
                     },
                     {
                       "key": "boolean.attribute",
                       "value": {
                         "boolValue": true
                       }
                     },
                     {
                       "key": "int.attribute",
                       "value": {
                         "intValue": "10"
                       }
                     },
                     {
                       "key": "double.attribute",
                       "value": {
                         "doubleValue": 637.704
                       }
                     },
                     {
                       "key": "array.attribute",
                       "value": {
                         "arrayValue": {
                           "values": [
                             {
                               "stringValue": "many"
                             },
                             {
                               "stringValue": "values"
                             }
                           ]
                         }
                       }
                     },
                     {
                       "key": "map.attribute",
                       "value": {
                         "kvlistValue": {
                           "values": [
                             {
                               "key": "some.map.key",
                               "value": {
                                 "stringValue": "some value"
                               }
                             }
                           ]
                         }
                       }
                     }
                   ]
                 }
               ]
             }
           ]
         }
       ]
      }'
      
    • you will be able to see SHA512 value on console
      ObservedTimestamp: 2018-12-13 14:51:00.3 +0000 UTC
      Timestamp: 2018-12-13 14:51:00.3 +0000 UTC
      SeverityText: Information
      SeverityNumber: Info2(10)
      Body: Str(Example log record)
      Attributes:
           -> string.attribute: Str(6cbe75a224033d0f145fd67e02cab35ce42a10cd1aa7b7030dd74e31af97037f2020d063305bc2552d1b9e43ca15872ea248c5b236df98085c690932a7f0ea49)
           -> boolean.attribute: Bool(true)
           -> int.attribute: Int(10)
           -> double.attribute: Double(637.704)
           -> array.attribute: Slice(["many","values"])
           -> map.attribute: Map({"some.map.key":"some value"})
      Trace ID: 5b8efff798038103d269b633813fc60c
      Span ID: eee19b7ec3c1b174
      

Documentation:

  • Added to OTTL readme and changelogs generated. Let me please know if I am missing any doc references.

Copy link

linux-foundation-easycla bot commented Jul 11, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@atoulme
Copy link
Contributor

atoulme commented Jul 13, 2024

Looks good, kicking off CI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants