Skip to content

Enforce fallback values for TraceOptions namespace root; expose PrometheusSimple DoS protection params#5

Merged
mgmeier merged 5 commits intomasterfrom
mkarg/configs
Apr 2, 2026
Merged

Enforce fallback values for TraceOptions namespace root; expose PrometheusSimple DoS protection params#5
mgmeier merged 5 commits intomasterfrom
mkarg/configs

Conversation

@mgmeier
Copy link
Copy Markdown
Contributor

@mgmeier mgmeier commented Mar 31, 2026

List of changes

  • Add PrometheusSimpleRun data type and field TraceConfig.tcPrometheusSimpleRun. This exposes some of the DoS protection parameters of the PrometheusSimple backend.
  • The above parameters can be set via the top-level config key "TracePrometheusSimpleRun": {...}. Those values will selectively override the hardcoded ones from defaultRunParams.
  • Add Cardano.Logging.Prometheus.TCPServer.runPrometheusSimpleWith to run the backend providing a custom PrometheusSimpleRun value.
  • Generelly relax some of the DoS protection default values.
  • Fix emptyTraceConfig to be actually empty.
  • Implement the basics for the future way of providing configuration via the top-level config key "HermodTracing".
  • This config key can reference an external file, or provide an object cleanly encapsulating all of Hermod's options. The option names are shortened wrt. the current top-level names.
  • Support !include extension for YAML config files.
  • The namespace root in "TraceOptions": { "": {...}} can now be aliased as '_root_': "TraceOptions": { "_root_": {...}}. This facilitates automations that have to treat an empty JSON string as special case.
  • Module Cardano.Logging.ConfigurationParser:
    • Add readConfigurationWithFallback and readConfigurationWithFallbackAndDefault, applying fallback values to the namespace root. These will be used iff no such value was given in the file or default config, and guard against accidentally missing trace output.
    • Add mkConfiguration and readConfigurationWithFallback convenience functions that will yield a minimal viable configuration by applying fallback values to emptyTraceConfig.
    • Add readConfiguration' and readConfigurationWithFallback' which will silently provide a minimal viable config if the file can't be found.
    • Expose applyFallback for those who want to safeguard some hand-rolled config value.
    • readConfiguration and readConfigurationWithDefault will now guarantee fallback values: Notice severity, DNormal detail level and Stdout MachineFormat JSON logging.
  • Add docuResultsToNamespaces to DocuGenerator to support JSON schema generation.

Furthermore, there's some general cleanup in this PR.

NB: Even though the PR introduces the new HermodTracing config format, the current cardano-node configuration cannot be represented in it, and needs to stay as-is - this would require API-breaking changes to data types. The new format targets new applications that adopt Hermod, and require a clean config interface which does not contain assumptions motivated by the cardano-node case.

@mgmeier mgmeier force-pushed the mkarg/configs branch 4 times, most recently from aa1805b to 1758192 Compare April 1, 2026 11:50
@mgmeier mgmeier changed the title Mkarg/configs Enforce fallback values for TraceOptions namespace root; expose PrometheusSimple DoS protection params Apr 1, 2026
@mgmeier mgmeier marked this pull request as ready for review April 1, 2026 14:24
@mgmeier mgmeier requested a review from a team April 1, 2026 14:24
mgmeier added a commit that referenced this pull request Apr 1, 2026
mgmeier added a commit that referenced this pull request Apr 2, 2026
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parser no longer strips the "Cardano" namespace prefix from config keys, which is a compatibility regression for existing configs. The previous implementation explicitly normalized "Cardano." to "" in the base version of ConfigurationParser.hs. The new code in the PR version removes that normalization entirely. Unless every caller has already stopped using Cardano.* keys, this will make previously working namespace overrides stop matching.

Copy link
Copy Markdown
Contributor Author

@mgmeier mgmeier Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, and yes, this is intentional.
Internally, IOE has stopped using the Cardano.* namespace prefix for quite some time, as evidenced by https://github.com/input-output-hk/iohk-nix/blob/master/cardano-lib/generic-log-config.nix and consequently https://github.com/IntersectMBO/cardano-node/blob/master/configuration/cardano/mainnet-config.json.

External users migrating now from the legacy system won't even be tempted to use that prefix in the first place, as there's no base in the legacy tracing config to use it at all (cf. https://github.com/input-output-hk/iohk-nix/blob/master/cardano-lib/generic-log-config-legacy.nix).

Metrics is the only remaining case where this needs coverage, which is already done by the existing TraceOptionMetricsPrefix config key.

, "TraceOptionLedgerMetricsFrequency" .= traceOptionLedgerMetricsFrequency
[ "Options" .= traceOptions
, "Forwarder" .= traceOptionForwarder
, "AppicationName" .= traceOptionNodeName
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
, "AppicationName" .= traceOptionNodeName
, "ApplicationName" .= traceOptionNodeName

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!



-- In the config object, if the "HermodTracing" value is not an Object itself but a String,
-- it will be interpreted as a file path reference to the actual tracing config object.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HermodTracing: "path/to/file.yaml" does not work, even though the PR description and comments say it should. In [trace-dispatcher/src/Cardano/Logging/ConfigurationParser.hs], ExternalFile is only decoded from the entire document being a bare YAML string. But parseAsOuter at lines 65-67 assumes HermodTracing contains an object and never handles the string case. So a config like HermodTracing: "./tracing.yaml" is rejected instead of redirecting.

Copy link
Copy Markdown
Contributor Author

@mgmeier mgmeier Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed; thank you.
Changed the instance FromJSON ExternalFile to process an object with a top-level key "HermodTracing".
Please revisit.

Comment thread trace-dispatcher/src/Cardano/Logging/ConfigurationParser.hs
@jutaro jutaro self-requested a review April 2, 2026 11:32
Copy link
Copy Markdown
Contributor

@jutaro jutaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now

@mgmeier mgmeier added this pull request to the merge queue Apr 2, 2026
Merged via the queue into master with commit 0af5e41 Apr 2, 2026
9 checks passed
@mgmeier mgmeier deleted the mkarg/configs branch April 2, 2026 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants