aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcorespi/index/eventlogger.cpp
blob: 5e07a940dba9324c3adb596ab727a30391694adc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "eventlogger.h"
#include <vespa/searchlib/util/logutil.h>

#include <vespa/log/log.h>
LOG_SETUP(".searchcorespi.index.eventlogger");

using vespalib::JSONStringer;
using search::util::LogUtil;

namespace searchcorespi::index {

void
EventLogger::diskIndexLoadStart(const vespalib::string &indexDir)
{
    JSONStringer jstr;
    jstr.beginObject();
    jstr.appendKey("input");
    LogUtil::logDir(jstr, indexDir, 6);
    jstr.endObject();
    EV_STATE("diskindex.load.start", jstr.toString().data());
}

void
EventLogger::diskIndexLoadComplete(const vespalib::string &indexDir,
                                   int64_t elapsedTimeMs)
{
    JSONStringer jstr;
    jstr.beginObject();
    jstr.appendKey("time.elapsed.ms").appendInt64(elapsedTimeMs);
    jstr.appendKey("input");
    LogUtil::logDir(jstr, indexDir, 6);
    jstr.endObject();
    EV_STATE("diskindex.load.complete", jstr.toString().data());
}

void
EventLogger::diskFusionStart(const std::vector<vespalib::string> &sources,
                             const vespalib::string &fusionDir)
{
    JSONStringer jstr;
    jstr.beginObject();
    jstr.appendKey("inputs");
    jstr.beginArray();
    for (size_t i = 0; i < sources.size(); ++i) {
        LogUtil::logDir(jstr, sources[i], 6);
    }
    jstr.endArray();
    jstr.appendKey("output");
    LogUtil::logDir(jstr, fusionDir, 6);
    jstr.endObject();
    EV_STATE("fusion.start", jstr.toString().data());
}

void
EventLogger::diskFusionComplete(const vespalib::string &fusionDir,
                                int64_t elapsedTimeMs)
{
    JSONStringer jstr;
    jstr.beginObject();
    jstr.appendKey("time.elapsed.ms").appendInt64(elapsedTimeMs);
    jstr.appendKey("output");
    LogUtil::logDir(jstr, fusionDir, 6);
    jstr.endObject();
    EV_STATE("fusion.complete", jstr.toString().data());
}

}