{"record":{"id":"9ff5a4e27474661e","repo":"apache/beam","slug":"sample-period-should-be-greater-than-1ms-got-v","errorCode":null,"errorMessage":"sample period should be greater than 1ms, got %v","messagePattern":"sample period should be greater than 1ms, got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/util/harnessopts/sampler.go","lineNumber":33,"sourceCode":"\npackage harnessopts\n\nimport (\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/apache/beam/sdks/v2/go/pkg/beam/core/util/hooks\"\n)\n\nconst (\n\tsamplePeriodHook = \"beam:go:hook:dofnmetrics:sampletime\"\n)\n\n// SampleInterval sets the sampling time period (greater than 1ms) for DoFn metrics sampling.\n// Default value is 200ms.\nfunc SampleInterval(samplePeriod time.Duration) error {\n\tif samplePeriod < time.Millisecond {\n\t\treturn fmt.Errorf(\"sample period should be greater than 1ms, got %v\", samplePeriod)\n\t}\n\tsampleTime := samplePeriod.String()\n\t// The hook itself is defined in beam/core/runtime/harness/sampler_hook.go\n\treturn hooks.EnableHook(samplePeriodHook, sampleTime)\n}\n","sourceCodeStart":15,"sourceCodeEnd":39,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/util/harnessopts/sampler.go#L15-L39","documentation":"SampleInterval sets the DoFn metrics sampling period for the Beam Go harness (default 200ms). This error is returned when the requested period is below 1ms, which the sampler cannot honor; the library refuses to enable the hook with such a value.","triggerScenarios":"Calling SampleInterval with a time.Duration smaller than time.Millisecond, e.g. SampleInterval(500 * time.Microsecond) or SampleInterval(0).","commonSituations":"Passing a bare integer (nanoseconds in Go's Duration) instead of a time.Duration, e.g. SampleInterval(100) meaning 100ns, when the developer intended 100ms.","solutions":["Pass an explicit time.Duration of at least time.Millisecond, e.g. SampleInterval(time.Millisecond).","If you wrote SampleInterval(200), change it to SampleInterval(200 * time.Millisecond).","If you want less sampling overhead, raise the interval (default 200ms) rather than lowering it below 1ms."],"exampleFix":"// before\nSampleInterval(100)\n// after\nSampleInterval(100 * time.Millisecond)","handlingStrategy":"validation","validationCode":"func validSamplePeriod(d time.Duration) bool { return d >= time.Millisecond }","typeGuard":null,"tryCatchPattern":"if err := harnessopts.SampleInterval(p); err != nil { return fmt.Errorf(\"SampleInterval(%v): %w\", p, err) }","preventionTips":["Always pass time.Duration values with explicit units; never pass bare integers.","Clamp requested periods to a floor of time.Millisecond before calling."],"tags":["go","configuration","duration","beam"],"backgroundTag":"invalid-argument-value","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}