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

Elastic Exporter: "400 Bad Request" exception #1269

Closed
cyrille-leclerc opened this issue Oct 14, 2020 · 3 comments · Fixed by #1371
Closed

Elastic Exporter: "400 Bad Request" exception #1269

cyrille-leclerc opened this issue Oct 14, 2020 · 3 comments · Fixed by #1371
Labels
bug Something isn't working

Comments

@cyrille-leclerc
Copy link
Member

Describe the bug

On OpenTelemetry Collector Contrib 0.12.0

Some messages sent by the OpenTelemetry Collector Elastic Exporter to Elastic APM Server are rejected with a "400 Bad Request" exception : the transaction.name length must be <= 1024, but got 1300".

This message seems has been received by the collector from a Java application instrumented with otel-java-agent 0.8.0.

This unexpected SQL request has been emitted by the PostgreSQL JDBC driver on the invocation of PgDatabaseMetaData#getTables (here).

This SQL request should have been reported by the otel java agent as a db.statement attribute according to OpenTelemetry Semantic Conventions / Databases.

Is it desired that it is reported as a transaction.name to Elastic APM?

{
   "level":"warn",
   "ts":1602686237.636788,
   "caller":"batchprocessor/batch_processor.go:166",
   "msg":"Sender failed",
   "component_kind":"processor",
   "component_type":"batch",
   "component_name":"batch",
   "error":"request failed with 400 Bad Request: {\"accepted\":28,\"errors\":[{\"message\":\"failed to validate transaction: error validating JSON: I[#] S[#] doesn't validate with \\\"transaction#\\\"\\n  I[#] S[#/allOf/1] allOf failed\\n    I[#/name] S[#/allOf/1/properties/name/maxLength] length must be \\u003c= 1024, but got 1300\",\"document\":\"{\\\"transaction\\\":{\\\"duration\\\":8.128237,\\\"id\\\":\\\"e7671a74e2fb3e6a\\\",\\\"name\\\":\\\"SELECT NULL AS TABLE_CAT, n.nspname AS TABLE_SCHEM, c.relname AS TABLE_NAME, CASE n.nspname ~ ? OR n.nspname = ? WHEN true THEN CASE WHEN n.nspname = ? OR n.nspname = ? THEN CASE c.relkind WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? ELSE NULL END WHEN n.nspname = ? THEN CASE c.relkind WHEN ? THEN ? WHEN ? THEN ? ELSE NULL END ELSE CASE c.relkind WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? ELSE NULL END END WHEN false THEN CASE c.relkind WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? ELSE NULL END ELSE NULL END AS TABLE_TYPE, d.description AS REMARKS, ? as TYPE_CAT, ? as TYPE_SCHEM, ? as TYPE_NAME, ? AS SELF_REFERENCING_COL_NAME, ? AS REF_GENERATION FROM pg_catalog.pg_namespace n, pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_description d ON (c.oid = d.objoid AND d.objsubid = ?) LEFT JOIN pg_catalog.pg_class dc ON (d.classoid=dc.oid AND dc.relname=?) LEFT JOIN pg_catalog.pg_namespace dn ON (dn.oid=dc.relnamespace AND dn.nspname=?) WHERE c.relnamespace = n.oid AND n.nspname LIKE ? AND c.relname LIKE ? AND (false OR ( c.relkind = ? AND n.nspname !~ ? AND n.nspname \\\\u003c\\\\u003e ? ) OR ( c.relkind = ? AND n.nspname \\\\u003c\\\\u003e ? AND n.nspname \\\\u003c\\\\u003e ? ) OR ( c.relkind = ? ) ) ORDER BY TABLE_TYPE,TABLE_SCHEM,TABLE_NAME \\\",\\\"span_count\\\":{\\\"dropped\\\":0,\\\"started\\\":0},\\\"timestamp\\\":1602686233842001,\\\"trace_id\\\":\\\"9372cfb9427237a27558ac1c9c65071b\\\",\\\"type\\\":\\\"unknown\\\",\\\"context\\\":{\\\"service\\\":{\\\"framework\\\":{\\\"name\\\":\\\"io.opentelemetry.auto.jdbc\\\",\\\"version\\\":\\\"0.8.0\\\"}},\\\"tags\\\":{\\\"db_connection_string\\\":\\\"postgresql://localhost:5432\\\",\\\"db_user\\\":\\\"test\\\",\\\"db_statement\\\":\\\"SELECT NULL AS TABLE_CAT, n.nspname AS TABLE_SCHEM, c.relname AS TABLE_NAME, CASE n.nspname ~ ? OR n.nspname = ? WHEN true THEN CASE WHEN n.nspname = ? OR n.nspname = ? THEN CASE c.relkind WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? ELSE NULL END WHEN n.nspname = ? THEN CASE c.relkind WHEN ? THEN ? WHEN ? THEN ? ELSE NULL END ELSE CASE c.relkind WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? ELSE NULL END END WHEN false THEN CASE c.relkind WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? ELSE NULL END ELSE NULL END AS TABLE_TYPE, d.description AS REMARKS, ? as TYPE_CAT, ? as TYPE_SCHEM, ? as TYPE_NAME, ? AS SELF_REFERENCING_COL_NAME, ? AS REF_GENERATION FROM pg_catalog.pg_namespace n, pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_description d ON (c.oid = d.objoid AND d.objsubid = ?) LEFT JOIN pg_catalog.pg_class dc ON (d.classoid=dc.oid AND dc.relname=?) LEFT JOIN pg_catalog.pg_namespace dn ON (dn.oid=dc.relnamespace AND dn.n\\\",\\\"db_system\\\":\\\"postgresql\\\",\\\"thread_name\\\":\\\"task-1\\\",\\\"thread_id\\\":328,\\\"db_name\\\":\\\"test\\\"}},\\\"result\\\":\\\"STATUS_CODE_OK\\\"}}\"},{\"message\":\"failed to validate transaction: error validating JSON: I[#] S[#] doesn't validate with \\\"transaction#\\\"\\n  I[#] S[#/allOf/1] allOf failed\\n    I[#/name] S[#/allOf/1/properties/name/maxLength] length must be \\u003c= 1024, but got 1052\",\"document\":\"{\\\"transaction\\\":{\\\"duration\\\":14.160108,\\\"id\\\":\\\"bee21be20f64c081\\\",\\\"name\\\":\\\"SELECT * FROM (SELECT n.nspname,c.relname,a.attname,a.atttypid,a.attnotnull OR (t.typtype = ? AND t.typnotnull) AS attnotnull,a.atttypmod,a.attlen,t.typtypmod,row_number() OVER (PARTITION BY a.attrelid ORDER BY a.attnum) AS attnum, nullif(a.attidentity, ?) as attidentity,pg_catalog.pg_get_expr(def.adbin, def.adrelid) AS adsrc,dsc.description,t.typbasetype,t.typtype FROM pg_catalog.pg_namespace n JOIN pg_catalog.pg_class c ON (c.relnamespace = n.oid) JOIN pg_catalog.pg_attribute a ON (a.attrelid=c.oid) JOIN pg_catalog.pg_type t ON (a.atttypid = t.oid) LEFT JOIN pg_catalog.pg_attrdef def ON (a.attrelid=def.adrelid AND a.attnum = def.adnum) LEFT JOIN pg_catalog.pg_description dsc ON (c.oid=dsc.objoid AND a.attnum = dsc.objsubid) LEFT JOIN pg_catalog.pg_class dc ON (dc.oid=dsc.classoid AND dc.relname=?) LEFT JOIN pg_catalog.pg_namespace dn ON (dc.relnamespace=dn.oid AND dn.nspname=?) WHERE c.relkind in (?,?,?,?,?) and a.attnum \\\\u003e ? AND NOT a.attisdropped AND n.nspname LIKE ?) c WHERE true AND attname LIKE ? ORDER BY nspname,c.relname,attnum \\\",\\\"span_count\\\":{\\\"dropped\\\":0,\\\"started\\\":0},\\\"timestamp\\\":1602686233852001,\\\"trace_id\\\":\\\"ddae42258fbff1ecee67089d9d6034be\\\",\\\"type\\\":\\\"unknown\\\",\\\"context\\\":{\\\"service\\\":{\\\"framework\\\":{\\\"name\\\":\\\"io.opentelemetry.auto.jdbc\\\",\\\"version\\\":\\\"0.8.0\\\"}},\\\"tags\\\":{\\\"db_connection_string\\\":\\\"postgresql://localhost:5432\\\",\\\"db_user\\\":\\\"test\\\",\\\"db_statement\\\":\\\"SELECT * FROM (SELECT n.nspname,c.relname,a.attname,a.atttypid,a.attnotnull OR (t.typtype = ? AND t.typnotnull) AS attnotnull,a.atttypmod,a.attlen,t.typtypmod,row_number() OVER (PARTITION BY a.attrelid ORDER BY a.attnum) AS attnum, nullif(a.attidentity, ?) as attidentity,pg_catalog.pg_get_expr(def.adbin, def.adrelid) AS adsrc,dsc.description,t.typbasetype,t.typtype FROM pg_catalog.pg_namespace n JOIN pg_catalog.pg_class c ON (c.relnamespace = n.oid) JOIN pg_catalog.pg_attribute a ON (a.attrelid=c.oid) JOIN pg_catalog.pg_type t ON (a.atttypid = t.oid) LEFT JOIN pg_catalog.pg_attrdef def ON (a.attrelid=def.adrelid AND a.attnum = def.adnum) LEFT JOIN pg_catalog.pg_description dsc ON (c.oid=dsc.objoid AND a.attnum = dsc.objsubid) LEFT JOIN pg_catalog.pg_class dc ON (dc.oid=dsc.classoid AND dc.relname=?) LEFT JOIN pg_catalog.pg_namespace dn ON (dc.relnamespace=dn.oid AND dn.nspname=?) WHERE c.relkind in (?,?,?,?,?) and a.attnum \\\\u003e ? AND NOT a.attisdropped AND n.nspname LIKE ?) c WHERE true AND attname LIKE ? ORDER \\\",\\\"db_system\\\":\\\"postgresql\\\",\\\"thread_name\\\":\\\"task-1\\\",\\\"thread_id\\\":328,\\\"db_name\\\":\\\"test\\\"}},\\\"result\\\":\\\"STATUS_CODE_OK\\\"}}\"},{\"message\":\"failed to validate transaction: error validating JSON: I[#] S[#] doesn't validate with \\\"transaction#\\\"\\n  I[#] S[#/allOf/1] allOf failed\\n    I[#/name] S[#/allOf/1/properties/name/maxLength] length must be \\u003c= 1024, but got 1360\",\"document\":\"{\\\"transaction\\\":{\\\"duration\\\":11.230764,\\\"id\\\":\\\"c7e502ac3d90449f\\\",\\\"name\\\":\\\"SELECT NULL::text AS PKTABLE_CAT, pkn.nspname AS PKTABLE_SCHEM, pkc.relname AS PKTABLE_NAME, pka.attname AS PKCOLUMN_NAME, NULL::text AS FKTABLE_CAT, fkn.nspname AS FKTABLE_SCHEM, fkc.relname AS FKTABLE_NAME, fka.attname AS FKCOLUMN_NAME, pos.n AS KEY_SEQ, CASE con.confupdtype WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? ELSE NULL END AS UPDATE_RULE, CASE con.confdeltype WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? ELSE NULL END AS DELETE_RULE, con.conname AS FK_NAME, pkic.relname AS PK_NAME, CASE WHEN con.condeferrable AND con.condeferred THEN ? WHEN con.condeferrable THEN ? ELSE ? END AS DEFERRABILITY FROM pg_catalog.pg_namespace pkn, pg_catalog.pg_class pkc, pg_catalog.pg_attribute pka, pg_catalog.pg_namespace fkn, pg_catalog.pg_class fkc, pg_catalog.pg_attribute fka, pg_catalog.pg_constraint con, pg_catalog.generate_series(?, ?) pos(n), pg_catalog.pg_class pkic WHERE pkn.oid = pkc.relnamespace AND pkc.oid = pka.attrelid AND pka.attnum = con.confkey[pos.n] AND con.confrelid = pkc.oid AND fkn.oid = fkc.relnamespace AND fkc.oid = fka.attrelid AND fka.attnum = con.conkey[pos.n] AND con.conrelid = fkc.oid AND con.contype = ? AND pkic.relkind = ? AND pkic.oid = con.conindid AND fkn.nspname = ? AND fkc.relname = ? ORDER BY pkn.nspname,pkc.relname, con.conname,pos.n\\\",\\\"span_count\\\":{\\\"dropped\\\":0,\\\"started\\\":0},\\\"timestamp\\\":1602686233874001,\\\"trace_id\\\":\\\"b31d6ddefcd20e5a205a18312c828401\\\",\\\"type\\\":\\\"unknown\\\",\\\"context\\\":{\\\"service\\\":{\\\"framework\\\":{\\\"name\\\":\\\"io.opentelemetry.auto.jdbc\\\",\\\"version\\\":\\\"0.8.0\\\"}},\\\"tags\\\":{\\\"db_connection_string\\\":\\\"postgresql://localhost:5432\\\",\\\"db_user\\\":\\\"test\\\",\\\"db_statement\\\":\\\"SELECT NULL::text AS PKTABLE_CAT, pkn.nspname AS PKTABLE_SCHEM, pkc.relname AS PKTABLE_NAME, pka.attname AS PKCOLUMN_NAME, NULL::text AS FKTABLE_CAT, fkn.nspname AS FKTABLE_SCHEM, fkc.relname AS FKTABLE_NAME, fka.attname AS FKCOLUMN_NAME, pos.n AS KEY_SEQ, CASE con.confupdtype WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? ELSE NULL END AS UPDATE_RULE, CASE con.confdeltype WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? ELSE NULL END AS DELETE_RULE, con.conname AS FK_NAME, pkic.relname AS PK_NAME, CASE WHEN con.condeferrable AND con.condeferred THEN ? WHEN con.condeferrable THEN ? ELSE ? END AS DEFERRABILITY FROM pg_catalog.pg_namespace pkn, pg_catalog.pg_class pkc, pg_catalog.pg_attribute pka, pg_catalog.pg_namespace fkn, pg_catalog.pg_class fkc, pg_catalog.pg_attribute fka, pg_catalog.pg_constraint con, pg_catalog.generate_series(?, ?) pos(n), pg_catalog.pg_class pkic WHERE pkn.oid = pkc.relnamespace AND pkc.oid = pka.attrelid AND pka.\\\",\\\"db_system\\\":\\\"postgresql\\\",\\\"thread_name\\\":\\\"task-1\\\",\\\"thread_id\\\":328,\\\"db_name\\\":\\\"test\\\"}},\\\"result\\\":\\\"STATUS_CODE_OK\\\"}}\"},{\"message\":\"failed to validate transaction: error validating JSON: I[#] S[#] doesn't validate with \\\"transaction#\\\"\\n  I[#] S[#/allOf/1] allOf failed\\n    I[#/name] S[#/allOf/1/properties/name/maxLength] length must be \\u003c= 1024, but got 1300\",\"document\":\"{\\\"transaction\\\":{\\\"duration\\\":2.747041,\\\"id\\\":\\\"9ec6d6c62d51d109\\\",\\\"name\\\":\\\"SELECT NULL AS TABLE_CAT, n.nspname AS TABLE_SCHEM, c.relname AS TABLE_NAME, CASE n.nspname ~ ? OR n.nspname = ? WHEN true THEN CASE WHEN n.nspname = ? OR n.nspname = ? THEN CASE c.relkind WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? ELSE NULL END WHEN n.nspname = ? THEN CASE c.relkind WHEN ? THEN ? WHEN ? THEN ? ELSE NULL END ELSE CASE c.relkind WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? ELSE NULL END END WHEN false THEN CASE c.relkind WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? ELSE NULL END ELSE NULL END AS TABLE_TYPE, d.description AS REMARKS, ? as TYPE_CAT, ? as TYPE_SCHEM, ? as TYPE_NAME, ? AS SELF_REFERENCING_COL_NAME, ? AS REF_GENERATION FROM pg_catalog.pg_namespace n, pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_description d ON (c.oid = d.objoid AND d.objsubid = ?) LEFT JOIN pg_catalog.pg_class dc ON (d.classoid=dc.oid AND dc.relname=?) LEFT JOIN pg_catalog.pg_namespace dn ON (dn.oid=dc.relnamespace AND dn.nspname=?) WHERE c.relnamespace = n.oid AND n.nspname LIKE ? AND c.relname LIKE ? AND (false OR ( c.relkind = ? AND n.nspname !~ ? AND n.nspname \\\\u003c\\\\u003e ? ) OR ( c.relkind = ? AND n.nspname \\\\u003c\\\\u003e ? AND n.nspname \\\\u003c\\\\u003e ? ) OR ( c.relkind = ? ) ) ORDER BY TABLE_TYPE,TABLE_SCHEM,TABLE_NAME \\\",\\\"span_count\\\":{\\\"dropped\\\":0,\\\"started\\\":0},\\\"timestamp\\\":1602686233887002,\\\"trace_id\\\":\\\"e9bb3f8894b79ebbd54642d0c148da1f\\\",\\\"type\\\":\\\"unknown\\\",\\\"context\\\":{\\\"service\\\":{\\\"framework\\\":{\\\"name\\\":\\\"io.opentelemetry.auto.jdbc\\\",\\\"version\\\":\\\"0.8.0\\\"}},\\\"tags\\\":{\\\"db_connection_string\\\":\\\"postgresql://localhost:5432\\\",\\\"db_user\\\":\\\"test\\\",\\\"db_statement\\\":\\\"SELECT NULL AS TABLE_CAT, n.nspname AS TABLE_SCHEM, c.relname AS TABLE_NAME, CASE n.nspname ~ ? OR n.nspname = ? WHEN true THEN CASE WHEN n.nspname = ? OR n.nspname = ? THEN CASE c.relkind WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? ELSE NULL END WHEN n.nspname = ? THEN CASE c.relkind WHEN ? THEN ? WHEN ? THEN ? ELSE NULL END ELSE CASE c.relkind WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? ELSE NULL END END WHEN false THEN CASE c.relkind WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? ELSE NULL END ELSE NULL END AS TABLE_TYPE, d.description AS REMARKS, ? as TYPE_CAT, ? as TYPE_SCHEM, ? as TYPE_NAME, ? AS SELF_REFERENCING_COL_NAME, ? AS REF_GENERATION FROM pg_catalog.pg_namespace n, pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_description d ON (c.oid = d.objoid AND d.objsubid = ?) LEFT JOIN pg_catalog.pg_class dc ON (d.classoid=dc.oid AND dc.relname=?) LEFT JOIN pg_catalog.pg_namespace dn ON (dn.oid=dc.relnamespace AND dn.n\\\",\\\"db_system\\\":\\\"postgresql\\\",\\\"thread_name\\\":\\\"task-1\\\",\\\"thread_id\\\":328,\\\"db_name\\\":\\\"test\\\"}},\\\"result\\\":\\\"STATUS_CODE_OK\\\"}}\"},{\"message\":\"failed to validate transaction: error validating JSON: I[#] S[#] doesn't validate with \\\"transaction#\\\"\\n  I[#] S[#/allOf/1] allOf failed\\n    I[#/name] S[#/allOf/1/properties/name/maxLength] length must be \\u003c= 1024, but got 1073\",\"document\":\"{\\\"transaction\\\":{\\\"duration\\\":2.518808,\\\"id\\\":\\\"efdbf8c4ca053de0\\\",\\\"name\\\":\\\"SELECT * FROM (SELECT n.nspname,c.relname,a.attname,a.atttypid,a.attnotnull OR (t.typtype = ? AND t.typnotnull) AS attnotnull,a.atttypmod,a.attlen,t.typtypmod,row_number() OVER (PARTITION BY a.attrelid ORDER BY a.attnum) AS attnum, nullif(a.attidentity, ?) as attidentity,pg_catalog.pg_get_expr(def.adbin, def.adrelid) AS adsrc,dsc.description,t.typbasetype,t.typtype FROM pg_catalog.pg_namespace n JOIN pg_catalog.pg_class c ON (c.relnamespace = n.oid) JOIN pg_catalog.pg_attribute a ON (a.attrelid=c.oid) JOIN pg_catalog.pg_type t ON (a.atttypid = t.oid) LEFT JOIN pg_catalog.pg_attrdef def ON (a.attrelid=def.adrelid AND a.attnum = def.adnum) LEFT JOIN pg_catalog.pg_description dsc ON (c.oid=dsc.objoid AND a.attnum = dsc.objsubid) LEFT JOIN pg_catalog.pg_class dc ON (dc.oid=dsc.classoid AND dc.relname=?) LEFT JOIN pg_catalog.pg_namespace dn ON (dc.relnamespace=dn.oid AND dn.nspname=?) WHERE c.relkind in (?,?,?,?,?) and a.attnum \\\\u003e ? AND NOT a.attisdropped AND n.nspname LIKE ? AND c.relname LIKE ?) c WHERE true AND attname LIKE ? ORDER BY nspname,c.relname,attnum \\\",\\\"span_count\\\":{\\\"dropped\\\":0,\\\"started\\\":0},\\\"timestamp\\\":1602686233891001,\\\"trace_id\\\":\\\"c20278208f15116b7224b124dced5f34\\\",\\\"type\\\":\\\"unknown\\\",\\\"context\\\":{\\\"service\\\":{\\\"framework\\\":{\\\"name\\\":\\\"io.opentelemetry.auto.jdbc\\\",\\\"version\\\":\\\"0.8.0\\\"}},\\\"tags\\\":{\\\"db_connection_string\\\":\\\"postgresql://localhost:5432\\\",\\\"db_user\\\":\\\"test\\\",\\\"db_statement\\\":\\\"SELECT * FROM (SELECT n.nspname,c.relname,a.attname,a.atttypid,a.attnotnull OR (t.typtype = ? AND t.typnotnull) AS attnotnull,a.atttypmod,a.attlen,t.typtypmod,row_number() OVER (PARTITION BY a.attrelid ORDER BY a.attnum) AS attnum, nullif(a.attidentity, ?) as attidentity,pg_catalog.pg_get_expr(def.adbin, def.adrelid) AS adsrc,dsc.description,t.typbasetype,t.typtype FROM pg_catalog.pg_namespace n JOIN pg_catalog.pg_class c ON (c.relnamespace = n.oid) JOIN pg_catalog.pg_attribute a ON (a.attrelid=c.oid) JOIN pg_catalog.pg_type t ON (a.atttypid = t.oid) LEFT JOIN pg_catalog.pg_attrdef def ON (a.attrelid=def.adrelid AND a.attnum = def.adnum) LEFT JOIN pg_catalog.pg_description dsc ON (c.oid=dsc.objoid AND a.attnum = dsc.objsubid) LEFT JOIN pg_catalog.pg_class dc ON (dc.oid=dsc.classoid AND dc.relname=?) LEFT JOIN pg_catalog.pg_namespace dn ON (dc.relnamespace=dn.oid AND dn.nspname=?) WHERE c.relkind in (?,?,?,?,?) and a.attnum \\\\u003e ? AND NOT a.attisdropped AND n.nspname LIKE ? AND c.relname LIKE ?) c WHERE true AND \\\",\\\"db_system\\\":\\\"postgresql\\\",\\\"thread_name\\\":\\\"task-1\\\",\\\"thread_id\\\":328,\\\"db_name\\\":\\\"test\\\"}},\\\"result\\\":\\\"STATUS_CODE_OK\\\"}}\"}]}"
}
failed to validate transaction: 
error validating JSON: I[#] S[#] doesn't validate with "transaction#"
 [#] S[#/allOf/1] allOf failed
 I[#/name] S[#/allOf/1/properties/name/maxLength] length must be <= 1024, but got 1300"

Steps to reproduce

Monitor a Java Hibernate application that uses Hibernate with PostgreSQL

What did you expect to see?

No exception message in the Otel Collector logs.

What did you see instead?

The exception message shared above in the otel collector logs.

What version did you use?
Version: OpenTelemetry Collector Contrib 0.12.0 + Otel Java Agent 0.8.0

What config did you use?

extensions:
  zpages:
    endpoint: :55679

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: '127.0.0.1:55680'
  hostmetrics:
    collection_interval: 1m
    scrapers:
      cpu:
      load:
      memory:
#      filesystem:
#      network:

processors:
  batch: null
  queued_retry: null

exporters:
  elastic:
    apm_server_url: 'http://localhost:8200'
    secret_token: 'my_secret_token'
  logging:
    loglevel: info
  jaeger:
    endpoint: 'localhost:14250'
    insecure: true
  prometheus:
    endpoint: 0.0.0.0:8889

service:
  pipelines:
    metrics:
      receivers:
        - otlp
        - hostmetrics
      exporters:
        - logging
        - prometheus
        - elastic
    traces:
      receivers:
        - otlp
      processors:
        - batch
      exporters:
        - elastic
#        - jaeger
#        - logging
  extensions: [zpages]

Environment

OS: MacOS 0.15.7

Additional context
Add any other context about the problem here.

@cyrille-leclerc cyrille-leclerc added the bug Something isn't working label Oct 14, 2020
@cyrille-leclerc
Copy link
Member Author

cc @axw

@axw
Copy link
Contributor

axw commented Oct 15, 2020

This is coming from the span name, and so far we've been using the span name as-is.

We should at least be truncating the name to avoid this error, but ideally the name wouldn't be that long in the first place. The Elastic APM agents create a summary of SQL queries. In this particular case I think we would just call it "SELECT".

We could do the same when translating OTel database spans, when the span name is either the same as the statement or otherwise appears to be a complete SQL statement, and hasn't already been summarised by the instrumentation library.

@cyrille-leclerc
Copy link
Member Author

Understood, I didn't have in mind that the OpenTelemetry span.name could have reused the sql statement.

Maybe truncating the span name could help. I'm wondering if we could also raise the point to the otel-java-instrumentation project as reusing the entire SQL request in the span.name does not sound aligned with the specification statement:

The span name SHOULD be the most general string that identifies a
(statistically) interesting class of Spans,
rather than individual Span instances while still being human-readable.

Note that I found this specification clarification https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/api.md#span

The span name concisely identifies the work represented by the Span,
for example, an RPC method name, a function name,
or the name of a subtask or stage within a larger computation.
The span name SHOULD be the most general string that identifies a
(statistically) interesting class of Spans,
rather than individual Span instances while still being human-readable.
That is, "get_user" is a reasonable name, while "get_user/314159",
where "314159" is a user ID, is not a good name due to its high cardinality.
Generality SHOULD be prioritized over human-readability.

For example, here are potential span names for an endpoint that gets a
hypothetical account information:

Span Name Guidance
get Too general
get_account/42 Too specific
get_account Good, and account_id=42 would make a nice Span attribute
get_account/{accountId} Also good (using the "HTTP route")

tigrannajaryan pushed a commit that referenced this issue Oct 28, 2020
Ensure span names are no longer than 1024 runes, per the Elastic APM protocol's requirements. Span names longer than this will be truncated to 1024 runes.

There will be usability issues with such long span names. Ideally the span name would be shortened, e.g. by having the instrumentation summarise the database statement (as done in Elastic APM agents), or something more specific such as having instrumentation aware of the Postgres JDBC driver's `PgDatabaseMetaData#getTables` method, naming the span after that rather than the SQL that ensues.

**Link to tracking Issue:**

Fixes #1269

**Testing:**

Unit test added.
dyladan referenced this issue in dynatrace-oss-contrib/opentelemetry-collector-contrib Jan 29, 2021
ljmsc referenced this issue in ljmsc/opentelemetry-collector-contrib Feb 21, 2022
…orter (#1269)

* Export non monotonic counters as gauge values from the prometheus exporter

* Add a test to ensure the pre-existing LastValue pathway on the collector exports the last value

* Add a TODO around refactoring the prometheus test to verify metadata as well

Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Chinwendu20 referenced this issue in Chinwendu20/opentelemetry-collector-contrib Oct 19, 2022
Signed-off-by: Maureen <amaka013@gmail.com>
mx-psi pushed a commit that referenced this issue Oct 20, 2022
Fix #1269

Signed-off-by: Maureen <amaka013@gmail.com>

Signed-off-by: Maureen <amaka013@gmail.com>
shalper2 pushed a commit to shalper2/opentelemetry-collector-contrib that referenced this issue Dec 6, 2022
Fix open-telemetry#1269

Signed-off-by: Maureen <amaka013@gmail.com>

Signed-off-by: Maureen <amaka013@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants