{"record":{"id":"e29ca19544eb68cf","repo":"apache/skywalking","slug":"uncreated-metrics","errorCode":null,"errorMessage":"Uncreated metrics {}","messagePattern":"Uncreated metrics (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/meter/MeterSystem.java","lineNumber":727,"sourceCode":"            throw new UnexpectedException(e.getMessage(), e);\n        }\n    }\n\n    /**\n     * Create an {@link AcceptableValue} instance for streaming calculation. AcceptableValue instance is stateful,\n     * shouldn't do {@link AcceptableValue#accept(MeterEntity, Object)} once it is pushed into {@link\n     * #doStreamingCalculation(AcceptableValue)}.\n     *\n     * @param metricsName A defined metrics name. Use {@link #create(String, String, ScopeType, Class)} to define a new\n     *                    one.\n     * @param dataType    class type of the input of {@link AcceptableValue}\n     * @return usable an {@link AcceptableValue} instance.\n     */\n    public <T> AcceptableValue<T> buildMetrics(String metricsName,\n                                               Class<T> dataType) {\n        MeterDefinition meterDefinition = meterPrototypes.get(metricsName);\n        if (meterDefinition == null) {\n            throw new IllegalArgumentException(\"Uncreated metrics \" + metricsName);\n        }\n        if (!meterDefinition.getDataType().equals(dataType)) {\n            throw new IllegalArgumentException(\n                \"Unmatched metrics data type, request for \" + dataType.getName()\n                    + \", but defined as \" + meterDefinition.getDataType());\n        }\n\n        return meterDefinition.getMeterPrototype().createNew();\n    }\n\n    /**\n     * Active the {@link MetricsStreamProcessor#in(Metrics)} for streaming calculation.\n     *\n     * @param acceptableValue should only be created through {@link #create(String, String, ScopeType, Class)}\n     */\n    public void doStreamingCalculation(AcceptableValue acceptableValue) {\n        final long timeBucket = acceptableValue.getTimeBucket();\n        if (timeBucket == 0L) {","sourceCodeStart":709,"sourceCodeEnd":745,"githubUrl":"https://github.com/apache/skywalking/blob/102af09b4a56064e22050dded10e2c52e490d040/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/meter/MeterSystem.java#L709-L745","documentation":"buildMetrics(name, dataType) hands a caller a fresh AcceptableValue instance from the prototype registered under that metric name. If meterPrototypes has no entry for the name — the metric was never created via MeterSystem.create, was removed, or the name is spelled differently — it throws 'Uncreated metrics <name>'.","triggerScenarios":"MAL/LAL or custom analyzer code calls buildMetrics for a metric whose create() never ran on this node (e.g. the rule defining it failed earlier or was hot-removed); a typo or case difference between the create() name and the buildMetrics name; calling buildMetrics during startup before the meter rules were applied.","commonSituations":"Custom receiver plugins that reference a metric defined in a MAL file that failed to load; race at OAP boot between data arrival and rule application; renaming a metric in config but not in the code that reads it; a removed rule while buffered data still references the metric.","solutions":["Ensure create(metricsName, functionName, scopeType, dataType) ran successfully for exactly that name before any buildMetrics call — check OAP startup logs for rule apply errors","Align the name strings (case-sensitive) between the create site and the buildMetrics site","If the metric was hot-removed, stop the emitting pipeline or re-apply the rule that defines it"],"exampleFix":"// before\nAcceptableValue<Long> v = meterSystem.buildMetrics(\"service_cpm\", Long.class);\n// rule defines \"service_cpm_sum\" -> Uncreated metrics service_cpm\n\n// after\nAcceptableValue<Long> v = meterSystem.buildMetrics(\"service_cpm_sum\", Long.class);","handlingStrategy":"validation","validationCode":"// MeterSystem has no public lookup; track the names you created\nSet<String> created = ConcurrentHashMap.newKeySet();\ncreated.add(name); // after successful meterSystem.create(name, ...)\nif (!created.contains(name)) throw new IllegalStateException(\"Metric not created: \" + name);\nAcceptableValue<Long> v = meterSystem.buildMetrics(name, Long.class);","typeGuard":null,"tryCatchPattern":"try {\n    AcceptableValue<Long> v = meterSystem.buildMetrics(name, Long.class);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Uncreated metrics\")) {\n        log.warn(\"Metric {} not registered yet (rule not applied or removed); dropping sample\", name);\n        return; // drop or buffer instead of crashing the receiver\n    }\n    throw e;\n}","preventionTips":["Register all metrics during module prepare()/start() before data can arrive","Use a single constant for each metric name shared by create() and buildMetrics() call sites","Treat rule-apply failures at startup as fatal — later buildMetrics calls will fail confusingly otherwise"],"tags":["meter-system","mal","metric-naming","lifecycle","typo"],"backgroundTag":null,"analyzedSha":"102af09b4a56064e22050dded10e2c52e490d040","analyzedAt":"2026-08-14T10:47:52.647Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}